package leetCode.firstWeek;

import java.util.ArrayList;
import java.util.List;

public class Code_3 {
  public int lengthOfLongestSubstring(String s) {
    //        System.out.println(s.charAt(2));
    List<Character> person = new ArrayList<>();
    int count = 0;
    int max = 0;
    int j = 0;
    for (int i = 0; i < s.length(); i++) {
      j = i;
      count = 0;
      person = new ArrayList<>();
      while (j < s.length() && person.indexOf(s.charAt(j)) < 0) {
        person.add(s.charAt(j));
        count++;
        j++;
        if (count > max) {
          max = count;
        }
      }
    }
    return max;
  }
}
